package com.xyazm.order.controller;

import com.xyazm.order.domain.dto.LackDTO;
import com.xyazm.order.domain.param.ApplyAfterSaleParam;
import com.xyazm.order.domain.param.CancelOrderParam;
import com.xyazm.order.domain.param.LackParam;
import com.xyazm.order.domain.param.RevokeAfterSaleParam;
import com.xyazm.order.service.IAfterSaleService;
import com.xyazm.order.service.IOrderLackService;
import com.xyazm.order.service.IApplyAfterSaleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 订单中心-逆向售后业务接口
 * @Author: xuyou
 * @Date: 2022/6/6 13:46
 */
@RestController
@RequestMapping("/afterSale")
public class AfterSaleController {

    @Autowired
    private IAfterSaleService afterSaleService;

    @Autowired
    private IApplyAfterSaleService applyAfterSaleService;

    @Autowired
    private IOrderLackService orderLackService;

    /**
     * 缺品取消订单请求
     */
    @PostMapping("/lockItem")
    public LackDTO lockItem(@RequestBody LackParam param) {
        LackDTO result = orderLackService.lockItem(param);
        return result;
    }

    /**
     * 用户手动取消订单/超时未支付取消
     * @author xuyou
     * @date: 2022/6/6 13:58
     */
    @PostMapping("/cancelOrder")
    public void cancelOrder(@Valid @RequestBody CancelOrderParam param) {
        afterSaleService.cancelOrder(param);
    }

    /**
     * 用户发起退货售后
     * @author xuyou
     * @date: 2022/7/13 21:05
     */
    @PostMapping("/applyAfterSale")
    public void applyAfterSale(@RequestBody ApplyAfterSaleParam param) {
        applyAfterSaleService.applyAfterSale(param);
    }

    /**
     * 用户撤销售后申请
     * @author xuyou
     * 2022/7/20 0020 22:15
    */
    @PostMapping("/revokeAfterSale")
    public void revokeAfterSale(@RequestBody RevokeAfterSaleParam param) {
        applyAfterSaleService.revokeAfterSale(param);
    }


}
